package com.xbongbong.rule.symbol;

import com.alibaba.fastjson.JSONArray;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.rule.symbol.base.AbstractSymbol;

import java.util.Objects;

/**
 * 不等于判断
 * 适用类型:文本/数字/下拉/单选/关联数据/成员单选/部门单选/阶段推进器/流水号
 *
 * @author zheng.li
 **/
public class NotEqualSymbol extends AbstractSymbol {

    @Override
    public boolean operation() {
        if (attr.contains(FieldTypeEnum.SUB_FORM.getEsalias())) {
            //子表单
            JSONArray arrayValue = factJson.getJSONArray(attr);
            if (CollectionsUtil.isNotEmpty(arrayValue)) {
                return arrayValue.stream().noneMatch(v -> Objects.equals(v, conditionValue));
            }
        } else {
            return !Objects.equals(value,conditionValue);
        }
        return false;
    }
}
